/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AjoutRobot.java
 *
 * Created on 24 nov. 2011, 11:09:56
 */
package robotlion.view;

import java.awt.Frame;
import java.awt.Window;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author test
 */
public class AjoutRobot extends javax.swing.JDialog {

    private boolean dialogResult = false;
    
    public AjoutRobot(Frame owner) {
        super(owner);
        initComponents();
    }
    
    public String getSelectedName()
    {
        return jComboBox1.getSelectedItem().toString().substring(0,jComboBox1.getSelectedItem().toString().indexOf('|'));
    }
    
    public int getSelectedNiveauAccessibilityRobot()
    {
        return Integer.parseInt(jComboBox1.getSelectedItem().toString().substring(jComboBox1.getSelectedItem().toString().lastIndexOf('|')+1,jComboBox1.getSelectedItem().toString().length()));
    }
    
    public int getSelectedVitesseRobot()
    {
        return Integer.parseInt(jComboBox1.getSelectedItem().toString().substring(jComboBox1.getSelectedItem().toString().indexOf('|')+1,jComboBox1.getSelectedItem().toString().lastIndexOf('|')));
    }
    
    public boolean getIsAjouterClicked(){
        return dialogResult;
    }
    
    public void setJComboBox1(ArrayList<String> typeRobot)
    {
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(typeRobot.toArray()));    
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel3 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(robotlion.view.RobotLion.class).getContext().getResourceMap(AjoutRobot.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox1.setName("jComboBoxTypeRobot"); // NOI18N

        jButton2.setText(resourceMap.getString("buttonAnnuler.text")); // NOI18N
        jButton2.setToolTipText(resourceMap.getString("buttonAnnuler.toolTipText")); // NOI18N
        jButton2.setName("buttonAnnuler"); // NOI18N
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonAnnulerMouseClicked(evt);
            }
        });

        jButton3.setText(resourceMap.getString("buttonAjouter.text")); // NOI18N
        jButton3.setName("buttonAjouter"); // NOI18N
        jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonAjouterMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jComboBox1, 0, 248, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButton3)
                        .addGap(18, 18, 18)
                        .addComponent(jButton2)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton2)
                    .addComponent(jButton3))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonAjouterMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonAjouterMouseClicked
        this.dialogResult = true;
        this.setVisible(false);
    }//GEN-LAST:event_jButtonAjouterMouseClicked

    private void jButtonAnnulerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonAnnulerMouseClicked
        this.dialogResult = false;
        this.setVisible(false);
    }//GEN-LAST:event_jButtonAnnulerMouseClicked

    // <editor-fold defaultstate="collapsed" desc="Generated Code (field declaration">
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel3;
    // End of variables declaration//GEN-END:variables
    // </editor-fold>
}
